package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/5/10 11:06
 * @apiNote
 */

public class Test00495FindPoisonedDuration {

    public int findPoisonedDuration(int[] timeSeries, int duration) {
        int cnt = 0;
        for (int i = 0; i < timeSeries.length - 1; i++) {
            cnt += Math.min(timeSeries[i + 1] - timeSeries[i], duration);
        }
        return cnt + duration;
    }
}
